<template>
  <div>
    <div style="display: flex;align-items: center;justify-content: center;">
      <el-card style="width: 80%;margin-top: 30px">
        <div style="margin-bottom: 10px;margin-left:5px;font-size: 20px;font-weight: bold;">酒店订单</div>
        <div style="margin-bottom: 10px">
          <el-input style="width: 200px;margin: 0 5px" placeholder="查询酒店" v-model="hotel_name"></el-input>
          <el-button type="primary" @click="load()">查询</el-button>
          <el-button type="warning" @click="reset()">重置</el-button>
        </div>
        <el-table ref="userTable" :data="tableData" stripe
                  :header-cell-style="{backgroundColor:'aliceblue',color:'#666'}">
          <el-table-column prop="id" label="订单号"></el-table-column>
          <el-table-column prop="hotel_name" label="酒店名称"></el-table-column>
          <el-table-column prop="room_type" label="房间类型"></el-table-column>
          <el-table-column prop="price" label="价格 "></el-table-column>
          <el-table-column prop="status" label="订单状态"></el-table-column>
          <el-table-column prop="order_type" label="订单类型"></el-table-column>
        </el-table>
        <div style="margin: 10px 0">
          <el-pagination
              @current-change="handleCurrentChange"
              :current-page="pageNum"
              :page-sizes="[100, 200, 300, 400]"
              :page-size="pageSize"
              layout="total,  prev, pager, next"
              :total="total">
          </el-pagination>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
export default {
  name: "orders",
  data() {
    return {
      hotel_id: '',
      hotel_name:"",
      tableData: [],
      pageNum: 1,
      pageSize: 5,
      total: 0,
    }
  },
  created() {
    this.load()
  },
  methods: {
    load(pageNum) {
      if (pageNum) this.pageNum = pageNum
      this.$request.post('/orders_list/', {
        // "hotel_id": this.hotel_id,
        "hotel_name": this.hotel_name,
        "page_size": this.pageSize,
        "page_id": this.pageNum,
      }).then(res => {
        if (res.code === '200') {
          this.tableData = res.data.order_list
          this.total = res.data.item_amount
        } else if (res.code === '501') {
          this.$message.warning("无数据")
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    reset(){
      this.$message.success("重置成功")
      this.hotel_name = ""
      this.load(1)
    },
    handleCurrentChange(pageNum) {
      this.load(pageNum)
    },
  }
}
</script>
<style scoped>

</style>